#ifndef INTERPRETER_H
#define INTERPRETER_H
#include "Procedure.h"
#include "utils.h"
#include <iostream>
#include <map>
#include <vector>
#include <sstream>
#include <stack>
#include <list>
class Frame
{
public:
    friend Procedure *eval(string input, Frame *env);
    friend pair<string, vector<Procedure *>> formals(string s, Frame *env);
    friend double cal(stack<string> line, Frame *env);
    Frame(Frame *parent = nullptr);

    void def(string name, Procedure *expr); //for value binding.

    Frame *makeChild(vector<string> formals, vector<Procedure *> vals); //for function calling.

    Procedure *lookup(string name);

private:
    Frame *parent;
    map<string, Procedure *> bindings;
};

Procedure *apply(Procedure *pro, vector<Procedure> formals, Frame *env);
void singleThreeEye(string &src, int begin, int mid, int end, int end2, Frame *env);
void threeEye(string &src, Frame *env);
vector<string> cut(string fish, Frame *env);
vector<string> allSymbol(string fish, Frame *env);
stack<string> read(string line, Frame *env);
double cal(stack<string> line, Frame *env);
pair<string, vector<Procedure *>> formals(string s, Frame *env);
string read4Human(string line, Frame *env);
double convertFromString(string str);
double cal(stack<string> line, Frame *env);
Procedure *eval(string input, Frame *env);
//to get the head of a function call.
string gethead(string fish, Frame *env);
#endif